import { BehaviourNode } from "../BehaviorNode";
import { BehaviorTree } from "../BehaviorTree";
import { RunStatus } from "../IBehaviourTree";

export class Action extends BehaviourNode {
    constructor(name: string, func: () => Promise<any>) {
        super(name);
        this.Action = func;
    }
    async Tick(): Promise<any> {
        if (this.status == RunStatus.Running) {
            return RunStatus.Running;
        }
        this.status = RunStatus.Running;
        await this.Action()
        this.status = RunStatus.Completed;
        if (BehaviorTree.debug) {
            console.log('动作--', this.nodeName, this.status)
        }
        return this.status;
    }

    Action(): Promise<any> {
        return null
    }
}